write a function in python hackerrank

visit shbcf.ru